package sinpleFactory.order;

import sinpleFactory.pizza.Pizza;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author feng
 * @Date 2021/10/14 18:26
 */
public class OrderPizza2 {

    Pizza pizza = null;
    String orderType = "";
    public OrderPizza2() {

        do {
            orderType = getType();
            //原材料业务
            pizza = SimpleFactory2.createPizza(orderType);
            //订单相关业务
            if (pizza != null) {
                pizza.bake();
                pizza.cut();
                pizza.box();
            } else {
                System.out.println("运行失败");
                break;
            }

        } while (true);


    }


    public String getType() {
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("输入订购的类型");
            String str = reader.readLine();
            return str;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }
}
